import request from '@/config/axios'
import base_request from '@/config/axios'
export interface UserVO {
  id: number
  username: string
  account: string
  nickname: string
  deptId: number
  deptName: string
  postIds: string[]
  email: string
  mobile: string
  sex: number
  avatar: string
  loginIp: string
  status: number
  remark: string
  loginDate: Date
  createTime: Date
  password: string
  registerIp: string
  bindingId: number
  userCode: string
  userType: number
  schoolId: number
  collegeId: number
  majorId: number
  classesId: number
  reviewStatus: number
  weight: number
  height: number
  rawPassword: string
  idNumber: string
  address: string
  sourceType: number
  sourceId: string
  longitude: number
  latitude: number
  remarks: string
  userDevid: string
}

export interface UserReviewVO {
  id: number
  reviewRemark: string
  reviewStatus: number
}

export interface StudentUserVO {
  schoolId: string
  collegeId: string
  classesId: string
  studentId: string
}

// 学生生成用户
export const createStudentUser = (data: StudentUserVO) => {
  return base_request.base_post({ url: '/member/user/generate-student-user', data })
}

// 查询用户管理列表
export const getUserPage = (params: PageParam) => {
  return request.get({ url: '/member/user/page', params })
}

// 删除用户
export const deleteUser = (id: number) => {
  return request.delete({ url: '/member/user/delete?id=' + id })
}

// 审核用户
export const reviewUser = (data: UserReviewVO) => {
  return request.post({ url: '/member/user/review', data })
}

// 用户状态修改
export const updateUserStatus = (id: number, status: number) => {
  const data = {
    id,
    status
  }
  return request.put({ url: '/member/user/update-status', data: data })
}

// 重置密码
export const resetUserPwd = (id: number, password?: String) => {
  const data = {
    id,
    password
  }
  return request.put({ url: '/member/user/update-password', data: data })
}

// 解绑学生
export const unbindStudent = (id: number) => {
  return request.post({ url: '/member/user/unbind-student?userId=' + id })
}

// 修改手机号
export const updateUserMobile = (id: number, mobile?: String) => {
  const data = {
    id,
    mobile
  }
  return request.put({ url: '/member/user/update-mobile', data: data })
}

// 修改身份证号
export const updateUserIdNumber = (id: number, idNumber?: String) => {
  const data = {
    id,
    idNumber
  }
  return request.put({ url: '/member/user/update-id-number', data })
}

// 批量删除用户
export const batchDeleteUser = async (ids: Array<string>) => {
  return await request.delete({ url: `/member/user/batchDelete?ids=` + ids })
}
